package guoanmaker.operator.business.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import guoanmaker.operator.business.model.InRoundPhone;
import guoanmaker.operator.business.service.OperatorHotBusinessNewServiceInterface;
import guoanmaker.operator.helper.common.AjaxJson;
import guoanmaker.operator.helper.common.abstractobj.ApiController;
import io.swagger.annotations.ApiOperation;
/**
 * 
    * @ClassName: OperatorHotBusinessNewController  
    * @Description: 新版运营后台 APP热门商户 配置  
    * @author lsy  
    * @date 2017年12月15日 上午10:42:52    
    *
 */
@RestController
@RequestMapping(ApiController.OPERATOR_HOT_BUSINESS)
public class OperatorHotBusinessNewController {
	@Autowired
	private OperatorHotBusinessNewServiceInterface operatorHotBusinessNewServiceInterface;
	
	/**
	 * 
	    * @Title: saveOperatorHotBusinessNew  
	    * @Description: 新版保存热门服务商 APP
	    * @param @param inRoundPhone InRoundPhone中的OperatorHotBusinessNew数组 和cityCode
	    * @return AjaxJson      
	    * @throws
	 */
	@ApiOperation(value = "新版保存热门服务商", notes = "新版保存热门服务商")
	@PostMapping("saveOperatorHotBusinessNew")
	public AjaxJson saveOperatorHotBusinessNew(@RequestBody InRoundPhone inRoundPhone) {
		AjaxJson ajaxJson=new AjaxJson();
		try {
			operatorHotBusinessNewServiceInterface.delectAllBycitycode(inRoundPhone.getCityId());
			operatorHotBusinessNewServiceInterface.saveOperatorHotNewBusiness(inRoundPhone);
			ajaxJson.setSuccess(true).setStatus(200).setData(null).setMsg("操作成功");
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setData(null).setMsg("操作失败");
		}
		return ajaxJson;
	}
	/**
	 * 
	    * @Title: selectOperatorBusiness  
	    * @Description: 传入服务商编号 查询服务商是否存在  
	    * @param  busNumber 服务商编号
	    * @return AjaxJson      
	    * @throws
	 */
	@ApiOperation(value = "查询服务商是否存在", notes = "查询服务商是否存在")
	@PostMapping("selectOperatorBusiness")
	public AjaxJson selectOperatorBusiness(String busNumber) {
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(operatorHotBusinessNewServiceInterface.selectOperatorBusiness(busNumber)).setMsg("操作成功");
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setData(null).setMsg("操作失败");
		}
		return ajaxJson;
	}
	/**
	 * 
	    * @Title: findOperatorHotBusinessNew  
	    * @Description: 根据citycode 查询所有热门商户  
	    * @param @param cityCode
	    * @return AjaxJson      
	    * @throws
	 */
	@ApiOperation(value = "查询所有热门商户", notes = "查询所有热门商户")
	@PostMapping("findOperatorHotBusinessNew")
	public AjaxJson findOperatorHotBusinessNew(String cityCode) {
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(operatorHotBusinessNewServiceInterface.findOperatorHotBusinessNew(cityCode)).setMsg("操作成功");
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setData(null).setMsg("操作失败");
		}
		return ajaxJson;
	}

}
